//
//  BiDocuParser.m
//  TrunkIndustryManageSystem
//
//  Created by WT_lyy on 15/5/6.
//  Copyright (c) 2015年 李璐西. All rights reserved.
//

#import "BiDocuParser.h"
#import "JSONKit.h"

#import "MJExtension.h"
#import "BiCarLicense.h"
#import "BICarLicenseType.h"
#import "BiCarLiscenceComEntity.h"
@implementation BiDocuParser
SINGLE_INSTANCE_IMPLEMENTION(BiDocuParser)


//
+ (NSDictionary *)parserDoceuListEntity:(NSString*)jsonStr{
    
    NSDictionary * jsonDic = [jsonStr objectFromJSONStringWithParseOptions:JKParseOptionLooseUnicode];
    
    NSMutableArray * array = [NSMutableArray array];
    
    id data = jsonDic[@"data"];
    
    if ([data isKindOfClass:[NSArray class]]) {
        
        NSArray * dataArr = (NSArray *)data;
        
        for (int i =0; i< dataArr.count; i++) {
            
            NSDictionary * datDic = dataArr[i];
            
            NSDictionary * carLicenseTypeDic = datDic[@"carLicenseType"];
            
            NSDictionary * carLicenseDic = datDic[@"carLicense"];
            
            BICarLicenseType * carLType = [BICarLicenseType objectWithKeyValues:carLicenseTypeDic];
            
            BiCarLicense *carLic = [BiCarLicense objectWithKeyValues:carLicenseDic];
            
            BiCarLiscenceComEntity * entity = [[BiCarLiscenceComEntity alloc] init];
            
            entity.CarlisceType = carLType;
            entity.Carlisce = carLic;
            
            entity.Carlisce.ID = carLicenseDic[@"id"];
            
            [array addObject:entity];
        }

    }
    
    return [NSDictionary dictionaryWithObjectsAndKeys:jsonDic[@"response_status"],@"response_status",jsonDic[@"result_info"],@"result_info",array,@"data", nil];
}


//
+ (NSDictionary *)parserDoceuCommonEntity:(NSString*)jsonStr{
    
    NSDictionary * jsonDic = [jsonStr objectFromJSONStringWithParseOptions:JKParseOptionLooseUnicode];
    
    return jsonDic;
}

@end
